// 封装工具函数

// 本地存储

export const SET_TOKEN = (key, value) => {
  if (typeof value == 'object') {
    value = JSON.stringify(value)
  }
  window.localStorage.setItem(key, value)
}

// 本地获取

export const GET_TOKEN = (key) => {
  let data = window.localStorage.getItem(key)
  try {
    if (typeof data == 'object') {
      return data
    } else {
      return JSON.parse(data)
    }
  } catch (err) {
    return null
  }

}

// 本地删除

export const DEL_TOKEN = (key) => {
  window.localStorage.removeItem(key)

}
